/**
 * @file luogu/4656/main
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/6/4 23:55:01
 **/

#include <cstdio>
#include <cstring>
typedef unsigned long long ull;
const int P = 79;
int T, N;
char str[1000005];

int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%s", str);
    N = strlen(str);
    ull s1 = 0, s2 = 0, p = 1;
    int ans = 0;
    for (int i = 0; i < N / 2; ++i) {
      s1 = s1 * P + str[i];
      s2 = str[N - 1 - i] * p + s2;
      p = p * P;
      if (s1 == s2) {
        ans += 2;
        s1 = s2 = 0;
        p = 1;
      }
    }
    if (N % 2 || s1) ++ans;
    printf("%d\n", ans);
  }
  return 0;
}
